package com.hqd.ch03.v43.context.annotation;

import com.hqd.ch03.v43.config.BeanDefinition;
import com.hqd.ch03.v43.reader.xml.ParserContext;
import com.hqd.ch03.v43.reader.xml.parse.BeanDefinitionParser;
import com.hqd.ch03.v43.utils.StringUtils;
import org.w3c.dom.Element;

public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser {

    private static final String BASE_PACKAGE_ATTRIBUTE = "base-package";

    private static final String RESOURCE_PATTERN_ATTRIBUTE = "resource-pattern";

    private static final String USE_DEFAULT_FILTERS_ATTRIBUTE = "use-default-filters";

    private static final String ANNOTATION_CONFIG_ATTRIBUTE = "annotation-config";

    private static final String NAME_GENERATOR_ATTRIBUTE = "name-generator";

    private static final String SCOPE_RESOLVER_ATTRIBUTE = "scope-resolver";

    private static final String SCOPED_PROXY_ATTRIBUTE = "scoped-proxy";

    private static final String EXCLUDE_FILTER_ELEMENT = "exclude-filter";

    private static final String INCLUDE_FILTER_ELEMENT = "include-filter";

    private static final String FILTER_TYPE_ATTRIBUTE = "type";

    private static final String FILTER_EXPRESSION_ATTRIBUTE = "expression";
    private static final String CONFIG_LOCATION_DELIMITERS = ",; \t\n";

    @Override
    public BeanDefinition parse(Element element, ParserContext context) {
        String basePackage = element.getAttribute(BASE_PACKAGE_ATTRIBUTE);
        String[] basePackages = StringUtils.tokenizeToStringArray(basePackage, CONFIG_LOCATION_DELIMITERS);
        ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context.getRegistry());
        scanner.scan(basePackages);
        return null;
    }
}
